/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uniriotec.pm.prova.core;

import java.util.List;
import java.util.Set;
import uniriotec.pm.prova.api.DisciplinaService;
import uniriotec.pm.prova.dao.DAOFactory;
import uniriotec.pm.prova.dao.DisciplinaDAO;
import uniriotec.pm.prova.dto.DisciplinaDTO;
import uniriotec.pm.prova.dto.TopicoDTO;
import uniriotec.pm.prova.util.DAOUtil;

/**
 *
 * @author albertoapr
 */
public class SimpleDisciplinaService implements DisciplinaService {
private static DAOFactory factory = DAOUtil.getDAOFactory();
    @Override
    public void create(DisciplinaDTO disciplina) {
        DisciplinaDAO dao = factory.getDisciplinaDAO();
        dao.create(disciplina);
               
        
    }

    @Override
    public void update(DisciplinaDTO disciplina) {
        DisciplinaDAO dao = factory.getDisciplinaDAO();
        dao.update(disciplina);
    }

    @Override
    public void remove(int disciplinaId) {
        DisciplinaDAO dao = factory.getDisciplinaDAO();
        dao.remove(disciplinaId);
    }

    @Override
    public List<DisciplinaDTO> listAll() {
        DisciplinaDAO dao = factory.getDisciplinaDAO();
        return dao.listAll();
    }
 

    @Override
    public DisciplinaDTO searchById(int disciplinaId) {
        DisciplinaDAO dao = factory.getDisciplinaDAO();
        DisciplinaDTO disciplina = dao.searchById(disciplinaId);
        
        disciplina.setTopicos(dao.listTopicos(disciplinaId));
        return disciplina;
    }

 
    @Override
    public List<TopicoDTO> listTopicos(int disciplinaId) {
         DisciplinaDAO dao = factory.getDisciplinaDAO();
        return  (List<TopicoDTO>) dao.listTopicos(disciplinaId);
    }
    
}
